let arr = [1, 2, 3, 4 , 5, 6]

Array.prototype.my_reduece= function(cb,...args){
    let start,index = 0;
    if (args.length) {
        start = args[0]
    }else{
        start = this[0]
        index = 1
    }
    for (let i = index; i < this.length; i++) {
        start = cb(start, this[i], i, this)
      }
    


  return start
}

const res = arr.my_reduce((pre, item, index, arr) =>{
    // console.log(pre, item, index, arr)
    return pre+item //return的值赋回给pre
},0) //数组遍历完之后会返回最终的pre值